package com.shyt.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shyt.dao.SysDepartmentRequestVo;
import com.shyt.dao.SysDepartmentVo;
import com.shyt.mapper.SysDepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDepartmentImpl {

    @Autowired
    SysDepartmentMapper sysDepartmentMapper;


    public List<SysDepartmentVo> getLoginDepartments(Long id) {
       return sysDepartmentMapper.getLoginDepartments(id);
    }

    public List<SysDepartmentVo> getDepartments(String departmentNm) {


        QueryWrapper<SysDepartmentVo> sysDepartmentVoQueryWrapper = new QueryWrapper<>();
        //sysDepartmentVoQueryWrapper.eq("department_name",rcMap );
        //return sysDepartmentMapper.selectList(sysDepartmentVoQueryWrapper);
        return sysDepartmentMapper.getDepartments(departmentNm);
    }

    public List<SysDepartmentVo> getDepartmentXlk(Long id) {
        return sysDepartmentMapper.getDepartmentXlk(id);
    }

    public void addDepartment(SysDepartmentRequestVo sysDepartmentRequestVo) {
        sysDepartmentMapper.addDepartment(sysDepartmentRequestVo);
    }

    public List<SysDepartmentVo> selectDepartmentById(SysDepartmentRequestVo sysDepartmentRequestVo) {
        return sysDepartmentMapper.selectDepartmentById(sysDepartmentRequestVo.getPid());
    }

    public void editDepartment(SysDepartmentRequestVo sysDepartmentRequestVo) {
         sysDepartmentMapper.editDepartment(sysDepartmentRequestVo);
    }

    public void deleteDepartment(SysDepartmentRequestVo sysDepartmentRequestVo) {
        //sysDepartmentMapper.deleteDepartment(sysDepartmentRequestVo);
        sysDepartmentMapper.deleteById(sysDepartmentRequestVo.getId());
        sysDepartmentMapper.deleteUserDepartment(sysDepartmentRequestVo);
    }
}
